<?php
namespace Home\Controller;
use Think\Controller;

class IndexController extends PublicController {
	public function index() {

		$oop = M("product");
		//$oop->startTrans();
		$con['product_id'] = 2;
		$list = $oop->where($con)->find();
		//$list = $oop->lock(true)->where($con)->find();
		if ($list['product_quantity'] >= 1) {
			$result = $oop->where($con)->setDec("product_quantity", 1);
			//$result = $oop->lock(true)->where($con)->setDec("product_quantity", 1);
		}
		if ($result) {
			//$oop->commit();
		} else {
			//$oop->rollback();
		}

		$this->display();
	}
}